import { IsString, IsJSON, IsEnum, IsPhoneNumber, Min, IsOptional, IsBoolean, IsNumber, MinLength, MaxLength } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { UserEntity } from 'src/module/system/user/entities/sys-user.entity';

export enum StatusEnum {
  STATIC = '0',
  DYNAMIC = '1',
}

export class LoginDto {
  @ApiProperty({
    required: false,
    description: '验证码',
  })
  @IsOptional()
  @IsString()
  code?: string;

  @ApiProperty({
    required: true,
    description: '用户名',
  })
  @IsString()
  @MinLength(2)
  @MaxLength(10)
  username: string;

  @ApiProperty({
    required: true,
    description: '密码',
  })
  @IsString()
  @MinLength(5)
  @MaxLength(20)
  password: string;

  @ApiProperty({
    required: true,
    description: 'uuid',
  })
  @IsOptional()
  @IsString()
  uuid?: string;
}

export class RegisterDto extends LoginDto {}

export class ResLoginDto {
  @ApiProperty({ type: 'string', description: 'token秘钥' })
  token: string;
}

export class ResImageCaptchaDto {
  @ApiProperty({ type: 'boolean', description: '是否启用验证码' })
  captchaEnabled: boolean;

  @ApiProperty({ type: 'string', description: 'base64图片编码' })
  img: string;

  @ApiProperty({ type: 'string', description: 'uuid码' })
  uuid: string;
}

export class ResInfo {
  @ApiProperty({ type: [String], description: '权限标识', default: [] })
  permissions: string[];

  @ApiProperty({ type: [String], description: '角色标识', default: [] })
  roles: string[];

  @ApiProperty({ type: UserEntity, description: '用户信息' })
  user: UserEntity;
}
